package com.parking.status.sync.netty.client;

import com.parking.status.sync.netty.entity.ContentBase;
import com.parking.status.sync.netty.entity.RequestPre;
import com.parking.status.sync.netty.util.LocalInfo;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

/**
 * Created by Administrator on 2015/9/18.
 */
public class RequestInitialEncoder extends MessageToMessageEncoder<RequestPre> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, RequestPre content, List<Object> out) throws Exception {
        //可以添加一些值,如自增的流水号等
        content.setSeqno( (int)(content.getId() % Integer.MAX_VALUE) ); //这里先就用数据库里的id了
//        content.setSeqno(LocalInfo.getSeqNo());
        out.add(content);
    }
}
